//
//  SQLObjectStore
//
//  Created by Caue W. on 2011-03-07.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
package time.providers.sql;
import time.keys.KeyCache;
import time.runtime.ObjectStore;

private typedef Connection = #if php php.db.Connection #elseif neko neko.db.Connection #else #error Unsupported SQL Platform #end;

class SQLObjectStore implements ObjectStore
{
	public var activationDepth(get_activationDepth, set_actionDepth):Int;
	public var keyStore(get_keyStore, never):KeyStore;
	public var async(get_async, never):AsyncObjectStore;
	
	var _keyStore:KeyStore;
	public function new()
	{
		this._keyStore = new KeyCache();
	}
	
	private function get_keyStore() : KeyStore
	{
		return _keyStore;
	}
	
	
	public function insert<T>(obj : T, errorIfExists : Bool = true) : Key
	public function insertAll<T>(objs : Iterable<T>, errorIfExists : Bool = true) : ObjectHash<T, Key>;
	
	public function update<T>(obj : T) : Void;
	public function updateAll<T>(objs : Iterable<T>) : Void;
	
	public function sync(obj : Dynamic) : Void;
	public function syncAll(objs : Iterable<Dynamic>) : Void;
	
	public function delete<T>(obj : T) : Bool;
	
	public function get<T>(key : Key) : T;
	public function getWith<T>(c : Class<T>, key : String) : T;
	
	public function cleanup() : Void;
}